package auth

import "golang.org/x/crypto/bcrypt"

//加密密码
func Encrypt(source string) (string, error) {
	hashed, err := bcrypt.GenerateFromPassword([]byte(source), bcrypt.DefaultCost)
	return string(hashed), err
}

//比较密码
func Compare(hashed, password string) error {
	return bcrypt.CompareHashAndPassword([]byte(hashed), []byte(password))
}
